<?php

use yii\db\Migration;

/**
 * Class m191016_032632_group_member
 */
class m191016_032632_group_member extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="群组中间表"';
        $this->createTable('{{%group_member}}', [
            'id' => $this->primaryKey(),
            'member_id' => $this->Integer()->notNull()->comment('用户id'),
            'group_id' => $this->Integer()->notNull()->comment('群组id'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%group_member}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m191016_032632_group_member cannot be reverted.\n";

        return false;
    }
    */
}
